<?php

declare(strict_types=1);

namespace app\admin\controller;

use think\facade\Db;
use think\facade\Request;

class User
{
    public function list()
    {
        $page = Request::param('page');
        $page_size = Request::param('page_size');
        $list = Db::name('user')->order('uid', 'desc');
        $total = $list->select()->count();
        $user = $list->page((int)$page, (int)$page_size)->select()->each(function ($item, $key) {
            $item['nickname'] = userTextDecode($item['nickname']);
            return $item;
        });

        $data = [
            'data' => $user,
            'total' => $total
        ];
        return jsonData(1, '查询成功', $data);
    }
}
